cmake_minimum_required(VERSION 3.19)
project(opengl)

set(CMAKE_CXX_STANDARD 14)
aux_source_directory(src SOURCE)

include_directories(
        ${CMAKE_SOURCE_DIR}/include/
        ${CMAKE_SOURCE_DIR}/glfw/include/)

#添加第三方静态库 glfw
add_library(glfw STATIC IMPORTED)
set_target_properties(glfw PROPERTIES IMPORTED_LOCATION
        ${CMAKE_SOURCE_DIR}/glfw/lib-vc2017/glfw3.lib)
link_directories(${CMAKE_SOURCE_DIR}/glfw/lib-vc2017/)

#查找安装库opengl
find_package(OpenGL REQUIRED)
if(OPENGL_FOUND)
    message(STATUS "find libs ${OPENGL_LIBRARIES}")
endif()
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR})
add_executable(opengl_hello ${SOURCE} src/shader.h src/stb_image.h)
set_property(TARGET opengl_hello APPEND PROPERTY LINK_FLAGS "/NODEFAULTLIB:MSVCRT")
target_link_libraries(opengl_hello
        ${OPENGL_LIBRARIES}
        glfw
        )